package stack;

import java.util.ArrayList;
import java.util.List;
import java.util.Stack;

public class t1047 {
    public String removeDuplicates(String s) {
        Stack<Character> stack = new Stack();
        List<Character> l = new ArrayList();
        for (char c : s.toCharArray()) {

            if (!l.isEmpty() && l.getLast() == c) {
                l.removeLast();
            } else {
                l.add(c);
            }
        }

        if (l.isEmpty()) {
            return "";
        }

        StringBuilder sb = new StringBuilder();
        for (char c : l) {
            sb.append(c);
        }
        return sb.toString();

    }


}